package com.ayuku.commons;

/**
 * 
 * @author putu kusuma <putukn@gmail.com>
 *
 */
public class UtilCart {
	public final static String space       = "<td width='100'>&nbsp;</td>";
	public final static String kotak       = "<td height='100px' width='100px' style='background:url(c:/strukturorg/kotak.gif) no-repeat;'>&nbsp;</td>";
	public final static String sudutkiri       = "<td  height='30px'  width='100px' style='background:url(c:/strukturorg/sudutkiri.gif) no-repeat;'>&nbsp;</td>";
	public final static String datar       = "<td height='30px' width='100px' style='background:url(c:/strukturorg/datar.gif) no-repeat;'>&nbsp;</td>";
	public final static String tengaharahbawah = "<td height='30px'  width='100px' style='background:url(c:/strukturorg/tengaharahbawah.gif) no-repeat;'>&nbsp;</td>";
	public final static String tengaharahatas       = "<td height='30px'  width='100px' style='background:url(c:/strukturorg/tengaharahatas.gif)      no-repeat;'>&nbsp;</td>";
	public final static String tengaharahatasbawah  = "<td height='30px'  width='100px' style='background:url(c:/strukturorg/tengaharahatasbawah.gif) no-repeat;'>&nbsp;</td>";
	public final static String tengahvertikal       = "<td height='30px'  width='100px' style='background:url(c:/strukturorg/tengahvertikal.gif)      no-repeat;'>&nbsp;</td>";
	public final static String sudutkanan       = "<td height='30px'  width='100px' style='background:url(c:/strukturorg/sudutkanan.gif) no-repeat;'>&nbsp;</td>";

	
	public static String createSpace(Integer n){
		String str = "";
		for (int i=0; i< n; i++){
			str = str + space;
		}
		return str;
	}
	
	public static String createKotak(Integer number){
		String str = "";
		if (number == 1) {
			str = getStringKotakGanjil(0);
		} else if (number == 2) {
			str = getStringKotakGenap(1);
		} else if (number == 3) {
			str = getStringKotakGanjil(1);
		} else if (number == 4) {
			str = getStringKotakGenap(2);
		} else if (number == 5) {
			str = getStringKotakGanjil(2);
		} else if (number == 6) {
			str = getStringKotakGenap(3);
		} else if (number == 7) {
			str = getStringKotakGanjil(3);
		} else if (number == 8) {
			str = getStringKotakGenap(4);			
		} else if (number == 9) {
			str = getStringKotakGanjil(4);
		} else if (number == 10) {
			str = getStringKotakGenap(5);			
		} else if (number == 11) {
			str = getStringKotakGanjil(5);			
		} else if (number == 12) {
			str = getStringKotakGenap(6);			
		} else if (number == 13) {
			str = getStringKotakGanjil(6);
		} else if (number == 14) {
			str = getStringKotakGenap(7);			
		} else if (number == 14) {
			str = getStringKotakGanjil(7);			
		}
		return str;

	}
	
	public static String createCartDownline(Integer number) {
		String str = "";
		if (number == 1) {
			str = tengahvertikal;
		} else if (number == 2) {
			str = getStringSplGenap(0);
		} else if (number == 3) {
			str = getStringSplGanjil(0);
		} else if (number == 4) {
			str = getStringSplGenap(1);
		} else if (number == 5) {
			str = getStringSplGanjil(1);
		} else if (number == 6) {
			str = getStringSplGenap(2);
		} else if (number == 7) {
			str = getStringSplGanjil(2);
		} else if (number == 8) {
			str = getStringSplGenap(3);			
		} else if (number == 9) {
			str = getStringSplGanjil(3);
		} else if (number == 10) {
			str = getStringSplGenap(4);			
		} else if (number == 11) {
			str = getStringSplGanjil(4);			
		} else if (number == 12) {
			str = getStringSplGenap(5);			
		} else if (number == 13) {
			str = getStringSplGanjil(5);
		} else if (number == 14) {
			str = getStringSplGenap(6);			
		} else if (number == 14) {
			str = getStringSplGanjil(6);			
		}
		return str;
	}
	
	private static String getStringSplGanjil(Integer n){
		String str = sudutkiri;
		for (int i = 0; i <n; i++) {
			str = str + tengaharahbawah;
		}
		str = str + tengaharahatasbawah;
		for (int i = 0; i <n; i++) {
			str = str + tengaharahbawah;
		}
		str = str + sudutkanan;
		return str;
	}
	
	private static String getStringSplGenap(Integer n){
		String str = sudutkiri;
		for (int i = 0; i <n; i++) {
			str = str + tengaharahbawah;
		}
		str = str + tengaharahatas;
		for (int i = 0; i <n; i++) {
			str = str + tengaharahbawah;
		}
		str = str + sudutkanan;
		return str;
	}	
	
	private static String getStringKotakGanjil(Integer n){
		String str = "";
		
		for (int i = 0; i <n; i++) {
			str = str + kotak;
		}
		
		str = str + kotak;
		
		for (int i = 0; i <n; i++) {
			str = str + kotak;
		}
		return str;
	}
	
	private static String getStringKotakGenap(Integer n){
		String str = "";
		
		for (int i = 0; i <n; i++) {
			str = str + kotak;
		}
		
		str = str + space;
		
		for (int i = 0; i <n; i++) {
			str = str + kotak;
		}
		return str;
	}	

}
